package lcy.homework03.first;

import java.util.Objects;

/**
 * @ClassName: Item
 * @Description: 抽象类 Item
 * @author: 李春洋
 * @date: 2024/4/18 16:01
 * @Blog: https://
 */
public abstract class Item {
    protected String title;

    public Item(String title) {
        this.title = title;
    }

    public abstract void displayInfo();

    // equals 方法的实现
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        Item item = (Item) obj;
        return Objects.equals(title, item.title);
    }

    // hashCode 方法的实现
    @Override
    public int hashCode() {
        return Objects.hash(title);
    }

    // toString 方法的实现
    @Override
    public String toString() {
        return "Item{" +
                "title='" + title + '\'' +
                '}';
    }
}
